<template lang="pug">
  el-dialog(title="创建用户" :visible.sync="show" :close-on-click-modal="false" :show-close="false" width="400px")
    el-form(:model="form" label-width="80px")
      el-form-item(label="帐号" size="small")
        el-input(v-model="form.account")
      el-form-item(label="姓名" size="small")
        el-input(v-model="form.name")
      el-form-item(label="密码" size="small")
        el-input(v-model="form.password")
      el-form-item(label="确认密码" size="small")
        el-input(v-model="form.confirmPwd")
      el-form-item(label="手机号" size="small")
        el-input(v-model="form.mobilePhone")
      el-form-item(label="邮箱" size="small")
        el-input(v-model="form.email")
      el-button(type="primary" @click="doSubmit" size="small") 提交
      el-button(@click="cancel" size="small") 取消
</template>
<script>
  export default {
    data() {
      return {
        form: {
          account: "",
          name: "",
          password: "",
          mobilePhone: "",
          email: ""
        }
      }
    },
    props: ['show'],
    methods: {
      doSubmit() {
        this.$axios.post("/api/users", this.form)
        .then(res => {
          this.$success();
          this.show = "false"
          this.$emit('loadPage')
        });
      },
      cancel() {
        this.$emit("update:show", false)
      }
    }
  }
</script>